<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:59:"/www/jilly/public/../application/view/admin/love/photo.html";i:1545723369;s:45:"/www/jilly/application/view/layout/admin.html";i:1541172698;s:29:"static/html/admin_header.html";i:1542980281;s:29:"static/html/admin_footer.html";i:1542962976;}*/ ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="”Cache-Control”" content="”no-transform”">
    <meta http-equiv="”Cache-Control”" content="”no-siteapp”">
    <!-- 百度收录start -->
    <meta name="baidu-site-verification" content="fBCVU8Appn" />
    <!-- 百度收录end -->
    <meta name="keywords" content="Dink、QQ三国">
    <meta name="description" content="最业余的saas管理平台">
    <title><?php echo (isset($title) && ($title !== '')?$title:'Jilly的小宇宙'); ?></title>
    <link rel="stylesheet" type="text/css" href="/static/js/dink/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/static/js/dink/dink.css" />
    <script type="text/javascript" src="/static/js/dink/jquery.js"></script>
    <script type="text/javascript" src="/static/js/dink/pjax.js"></script>
    <script type="text/javascript" src="/static/js/dink/layui/layui.all.js"></script>
    <script type="text/javascript" src="/static/js/dink/layui/layui.js"></script>
    <script type="text/javascript" src="/static/js/dink/dink.js"></script>
    <script type="text/javascript" src="/static/js/dink/public.js"></script>
    <!--loading-->
    <style>
        .loading{-webkit-animation:transform-5 2s ease 500ms alternate none 1;animation:transform-5 500ms ease 500ms alternate none 1;}
        @-webkit-keyframes transform-5 {
            from{-webkit-transform:perspective(400px) rotateY(180deg);transform:perspective(400px) rotateY(180deg);}
            to{-webkit-transform:perspective(400px) rotateY(0deg);transform:perspective(400px) rotateY(0deg);}
        }
        @keyframes transform-5 {
            from{-webkit-transform:perspective(400px) rotateY(180deg);transform:perspective(400px) rotateY(180deg);}
            to{-webkit-transform:perspective(400px) rotateY(0deg);transform:perspective(400px) rotateY(0deg);}
        }
    </style>
    <!--loading-->
</head>

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo" style="cursor:pointer;"><?php echo PN; ?>后台管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item"><a href="">控制台</a></li>
            <li class="layui-nav-item"><a href="">商品管理</a></li>
            <li class="layui-nav-item">
                <a href="javascript:;">其它系统</a>
                <dl class="layui-nav-child">
                    <dd><a href="">邮件管理</a></dd>
                    <dd><a href="">消息管理</a></dd>
                </dl>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="">控制台<span class="layui-badge">9</span></a>
            </li>
            <li class="layui-nav-item">
                <a href="">个人中心<span class="layui-badge-dot"></span></a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="/static/img/index/favicon.ico" class="layui-nav-img">
                    <?php echo \think\Session::get('userInfo.nickname'); ?>
                </a>
                <dl class="layui-nav-child layui-anim layui-anim-upbit">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a id="logout" href="javascript:;">注销</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree">
                <!--遍历菜单start-->
                <?php foreach(\think\Session::get('sideMenu') as $value): ?>
                <li class="layui-nav-item">
                    <?php if(( (\think\Session::get('userInfo.permission') && in_array($value['permission'],\think\Session::get('userInfo.permission'))) || \think\Session::get('userInfo.role_id')==0 )): ?>
                    <a data-pjax href="<?php echo $value['href']; ?>" data-title="<?php echo $value['title']; ?>">
                        <?php echo $value['title'];?>
                    </a>
                    <?php endif; if(isset($value['menu'])){  ?>
                    <dl class="layui-nav-child">
                        <?php foreach($value['menu'] as $val): if(( (\think\Session::get('userInfo.permission') && in_array($val['permission'],\think\Session::get('userInfo.permission'))) || \think\Session::get('userInfo.role_id')==0 )): ?>
                        <dd><a data-pjax href="<?php echo $val['href']; ?>" data-title="<?php echo $val['title']; ?>"><?php echo $val['title']; ?></a></dd>
                        <?php endif; endforeach; ?>
                    </dl>
                    <?php  }  ?>
                </li>
                <?php endforeach; ?>
                <!--遍历菜单end-->
            </ul>
        </div>
    </div>

    <!--loading-->

    <!--loading-->

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;" id="dink-container">
            <!--主体页面-->

            <!--end-->


<script>
    $(function(){
        $(document).pjax('a[data-pjax]','#dink-container');
        $.pjax.reload('#dink-container')

        //pjax前后操作
        $(document).on('pjax:send',function(){
            // $('.layui-body').addClass('loading');
        });
        $(document).on('pjax:success',function(){
            // setTimeout(function(){
            //     $('.layui-body').removeClass('loading');
            // },1000);
            $('dd').removeClass('layui-this');
            var long = location.href;
            var short = location.hostname;
            var now = long.substr(long.indexOf(short)+short.length);
            $('dd').each(function(){
                var url = $(this).find('a').attr('href');
                if(url == now){
                    $(this).parents('.layui-nav-item').addClass('layui-nav-itemed');
                    $(this).addClass('layui-this');
                    $('title').text($(this).find('a').attr('data-title'));
                }
            });
        });

        //浏览器前后操作
        $(document).on('pjax:start',function(){
            // $('.layui-body').addClass('loading');
        });
        $(document).on('pjax:end', function() {
            // setTimeout(function(){
            //     $('.layui-body').removeClass('loading');
            // },1000);
            $('dd').removeClass('layui-this');
            var long = location.href;
            var short = location.hostname;
            var now = long.substr(long.indexOf(short)+short.length);
            $('dd').each(function(){
                var url = $(this).find('a').attr('href');
                if(url == now){
                    $(this).parents('.layui-nav-item').addClass('layui-nav-itemed');
                    $(this).addClass('layui-this');
                    $('title').text($(this).find('a').attr('data-title'));
                }
            });
        });

        SideMenu();
    });

    //监听子菜单点击
    $(document).on('click','dd',function(){
        $('dd').removeClass('layui-this');
        $(this).parents('.layui-nav-item').addClass('layui-nav-itemed');
        $(this).addClass('layui-this');
        $('title').text($(this).find('a').attr('data-title'));
    });

    //菜单根据页面选中
    function SideMenu(){
        var now = '/'+'<?php echo current_url(); ?>';
        $('dd').each(function(){
            var url = $(this).find('a').attr('href');
            if(url == now){
                $(this).parents('.layui-nav-item').addClass('layui-nav-itemed');
                $(this).addClass('layui-this');
                $('title').text($(this).find('a').attr('data-title'));
            }
        });
    }

    //注销
    $(document).on('click','#logout',function(){
        var url = '/handler/login/doLogout';
        var data = {};
        $.post(url,data,function(e){
            if(e.ret == 1){
                location.reload();
            }else{
                layer.msg(e.msg);
            }
        },'json');
    });

    //跳转首页
    $('.layui-logo').click(function(){
        location.href = '/admin/index';
    });

</script>
<!--<style>-->
<!--.layui-btn{margin:3px;}-->
<!--</style>-->

<div style="margin-left: 94%;">
    <a class="layui-btn layui-btn-primary layui-btn-sm operate" operate-type="add"><i class="layui-icon">&#xe608;</i>添加</a>
</div>

<table class="layui-table">
    <thead>
    <tr>
        <th width="5%;">ID</th>
        <th width="10%;">名称</th>
        <!--<th width="10%;">图示</th>-->
        <th width="10%;">大小</th>
        <!--<th width="10%;">备注</th>-->
        <th width="10%;">创建日期</th>
        <th width="10%;">操作</th>
    </tr>
    </thead>
    <tbody>

    </tbody>
</table>
<!--分页start-->
<div id="paginate"></div>
<!--分页end-->

<script>
    $(function(){
        GetTableList();
    });

    //获取表格数据
    function GetTableList(page=1,pagesize=10){
        var url = '/handler/love/getPhotoList';
        var data = {page:page,pagesize:pagesize};
        dink.post(url,data,function(res){
            if(res.ret == 1){
                var target = $('tbody');
                var html = '';
                $.each(res.data,function(i,ele){
                    html += '<tr>\n' +
                        '    <td>'+(i+1)+'</td>\n' +
                        '    <td>'+ele.title+'</td>\n' +
//                        '    <td><image style="width:50px;height:50px;" src="'+ele.cover+'" /></td>\n' +
                        '    <td>'+ele.size+'</td>\n' +
//                        '    <td>'+(ele.remark ? ele.remark.substr(0,10)+'...' : '')+'</td>\n' +
                        '    <td>'+dink.utd(ele.ctime)+'</td>\n' +
                        '    <td>\n' +
                        '        <a class="layui-btn layui-btn-xs operate" operate-type="delete" data-id="'+ele.id+'">删除</a>\n' +
                        '    </td>\n' +
                        '</tr>';
                });
                target.html(html);
                if(page == 1){
                    Paginate(res.total,pagesize);
                }
            }else{
                var target = $('tbody');
                var html = '<tr><td colspan="6">无数据</td></tr>';
                target.html(html);
                layer.msg(res.msg);return;
            }
        });
    }

    //分页
    function Paginate(count,pagesize){
        layui.use('laypage',function(){
            var laypage = layui.laypage;
            laypage.render({
                elem: 'paginate',
                count: count,
                limit: pagesize,
                layout: ['count', 'prev', 'page', 'next', 'skip'],
                jump: function(obj,first){
                    if(!first){
                        GetTableList(obj.curr,pagesize);
                    }
                }
            });
        });
    }

    //操作按钮click事件
    dink.click('.operate',function(){
        var operate_type = $(this).attr('operate-type');
        var id = $(this).attr('data-id');
        var root = $(this).attr('data-root');
        var nickname = $(this).attr('data-nickname');
        var role_id = $(this).attr('data-role_id');
        //判断权限
        dink.post('/handler/permission/checkOperatePermission',{permission:'love:photo:'+operate_type},function(res){
            if(res.ret == 1){
                AdminNewsOpreate(operate_type,id,root,nickname,role_id);
            }else{
                layer.msg(res.msg);return;
            }
        });
        //end
    });

    //添加/编辑新闻
    function AdminNewsOpreate(operate='add',id=0){
        if(operate == 'add'){
            dink.html('AdminLovePhotoAdd','添加照片',['100%','100%']);
        }else if(operate == 'delete'){
            dink.alert('Tips','确定删除？',function(){
                dink.post('/handler/love/deletePhoto',{id:id},function(res){
                    layer.msg(res.msg);
                    GetTableList();return;
                });
            });
        }else{
            layer.msg('操作类型异常');return;
        }
        //添加、编辑
        dink.click('#add',function(){
            var data = {};
            var base = {};
            if(operate == 'add'){
                var url = '/handler/love/addPhoto';
            }else{
                layer.msg('操作类型异常');return;
            }
            var imageArr = [];
            $('.upload_item').each(function(i,ele){
                if($(ele).children().eq(2).text() == '上传成功'){
                    var item = {};
                    item.title = $(ele).attr('data-title');
                    item.size = $(ele).attr('data-size');
                    item.cover = $(ele).attr('data-url');
                    imageArr.push(item);
                }
            });
            if(imageArr.length == 0){
                layer.msg('无有效上传图片');return;
            }
            //end
            data.base = imageArr;
            dink.alert('Tips','确定'+(operate=='add' ? '添加' : '编辑')+'照片？',function(){
                dink.post(url,data,function(res){
                    if(res.ret == 1){
                        dink.close(res.msg);
                        GetTableList();
                    }else{
                        layer.msg(res.msg);
                    }
                });
            });
        });
    }
</script>
</div>
</div>

<div class="layui-footer" align="center">
    <!-- 底部固定区域 -->
    © dink.xyz - <?php echo PN; ?>后台管理系统
</div>
</div>
</body>
</html>